//
//  LXCarSignListTableViewCell.m
//  ZuLinProject
//
//  Created by bancheng on 2022/9/5.
//  Copyright © 2022 LX_App. All rights reserved.
//

#import "LXCarSignListTableViewCell.h"
#import "LXSignContractModel.h"
@implementation LXCarSignListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.backView addCorner:4];
    [self.btn1 setIconInRightWithSpacing:3];
    [self.label9 setBackgroundColor:[ColorWith3C6CFC colorWithAlphaComponent:0.1]];
    [self.label9 addCorner:1];
    [self.label7 addCorner:2];
    [self.label8 addCorner:2];
}

- (void)setModel:(LXSignContractModel *)model{
    _model = model;
    
    self.label1.text = [NSString stringWithNull:model.carNum];
    [self.btn1 setTitle:[NSString stringWithNull:model.driverName] forState:UIControlStateNormal];
    [self.btn1 setIconInRightWithSpacing:3];
    self.label2.text = @"客户姓名";
    self.label2.textColor = ColorWithAAAAAA;
    
    self.label3.text = [NSString stringWithFormat:@"签约日期  %@",[NSString stringWithNull:model.signDate]];
    [self.label3 addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"签约日期"];
    self.label4.text = [NSString stringWithFormat:@"租金押金  %@/%@",[NSString toTen:model.rent],[NSString toTen:model.depost]];
    [self.label4 addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"租金押金"];
    self.label5.text = [NSString stringWithFormat:@"合同日期  %@ / %@",[NSString stringWithNull:model.beginTime],[NSString stringWithNull:model.endTime]];
    [self.label5 addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"合同日期"];
    self.label6.text = [NSString stringWithFormat:@"利行联系人：%@",!StringIsEmpty(model.businessName)?model.businessName:@"无"];
    
    if (model.signType == 1) {
        self.label9.text = @"租车";
    }
    else if(model.signType == 2){
        self.label9.text = @"购车";
    }
    else if(model.signType == 3){
        self.label9.text = @"以租代购";
    }
    self.label9Const.constant = [NSString getLabelOptimumWidth:self.label9 WithFont:12] + 3;
    
    if (model.fromType == 2) {
        self.label7.hidden = NO;
        self.label8.hidden = NO;
        // 司机待确认
        if (model.driverComfirmStat == 1) {
    
            self.label8.textColor = mainColor;
            self.label8.backgroundColor = [mainColor colorWithAlphaComponent:0.1];
            self.label8.text = @"司机已确认";
        }
        else {
            self.label8.textColor = ColorWithEA545A;
            self.label8.backgroundColor = [ColorWithEA545A colorWithAlphaComponent:0.1];
            self.label8.text = @"司机待确认";
        }
        // 企业待确认
        if (model.companyComfirmStat == 1) {
            self.label7.textColor = mainColor;
            self.label7.backgroundColor = [mainColor colorWithAlphaComponent:0.1];
            self.label7.text = @"企业已确认";
        }
        else {
            self.label7.textColor = ColorWithEA545A;
            self.label7.backgroundColor = [ColorWithEA545A colorWithAlphaComponent:0.1];
            self.label7.text = @"企业待确认";
        }
        
    }
    else {
        self.label7.hidden = YES;
        self.label8.hidden = YES;
    }
    
}
- (void)setSignModel:(LXSignContractModel *)signModel{
    _signModel = signModel;
    
    NSString *carBrand = [NSString stringWithFormat:@"%@ %@",signModel.carBrand,signModel.carModel];
    self.label1.text = [NSString stringWithFormat:@"%@ %@",[NSString stringWithNull:signModel.carNum],carBrand];
    self.label1.textColor = Color333;
    [self.label1 addAttributes:TextAttrCorlor(Color333) forText:carBrand size:[UIFont systemFontOfSize:12]];
    
    self.label2.text = @"客户姓名";
    self.label2.textColor = ColorWithAAAAAA;
    
    [self.btn1 setImage:nil forState:UIControlStateNormal];
    [self.btn1 setTitle:[NSString stringWithFormat:@"    %@",signModel.driverName] forState:UIControlStateNormal];
    [self.btn1 setTitleColor:Color333 forState:UIControlStateNormal];
   
    
    self.label3.textColor = Color333;
    self.label3.text = [NSString stringWithFormat:@"签约日期  %@",[NSString stringWithNull:signModel.signDate]];
    [self.label3 addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"签约日期"];
    
    
    self.label4.textColor = Color333;
    if (signModel.signType == 1) {
        self.label4.text = [NSString stringWithFormat:@"租金押金  %@ / %@",[NSString toTen:signModel.rent],[NSString toTen:signModel.depost]];
        [self.label4 addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"租金押金"];

    }
    else {
        self.label4.text = [NSString stringWithFormat:@"月供首付  %@ / %@",[NSString toTen:signModel.rent],[NSString toTen:signModel.depost]];
        [self.label4 addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"月供首付"];


    }
    
    self.label5.text = [NSString stringWithFormat:@"合同日期  %@ 至 %@",[NSString stringWithNull:signModel.beginTime],[NSString stringWithNull:signModel.endTime]];
    self.label5.textColor = Color333;

    if (signModel.reNewFlag == 1 && signModel.signStatus != 3) {
        self.label5.textColor = ColorWithFF921C;
        [self.label5 addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"合同日期"];
    }
    else {
        self.label5.textColor = ColorWith333333;
        [self.label5 addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"合同日期"];
        [self.label5 addAttributesArray:@[TextAttrCorlor(ColorWithAAAAAA),TextAttrCorlor(ColorWithAAAAAA)] forStringArray:@[@"合同日期",@"至"] size:13];
    }
    

    
    
    self.label6.text = [NSString stringWithFormat:@"利行联系人：%@",!StringIsEmpty(signModel.businessName)?signModel.businessName:@"无"];
    self.label6.textColor = ColorWithAAAAAA;
    
    
   
  
    if (signModel.fromType == 2) {
        self.label7.hidden = NO;
        self.label8.hidden = NO;
        // 司机待确认
        if (signModel.driverComfirmStat == 1) {
    
            self.label8.textColor = mainColor;
            self.label8.backgroundColor = [mainColor colorWithAlphaComponent:0.1];
            self.label8.text = @"司机已确认";
        }
        else {
            self.label8.textColor = ColorWithEA545A;
            self.label8.backgroundColor = [ColorWithEA545A colorWithAlphaComponent:0.1];
            self.label8.text = @"司机待确认";
        }
        // 企业待确认
        if (signModel.companyComfirmStat == 1) {
            self.label7.textColor = mainColor;
            self.label7.backgroundColor = [mainColor colorWithAlphaComponent:0.1];
            self.label7.text = @"企业已确认";
        }
        else {
            self.label7.textColor = ColorWithEA545A;
            self.label7.backgroundColor = [ColorWithEA545A colorWithAlphaComponent:0.1];
            self.label7.text = @"企业待确认";
        }
        
    }
    else {
        self.label7.hidden = YES;
        self.label8.hidden = YES;
    }
    
    
    self.label9.hidden = YES;
    self.btn2.hidden = YES;
    
    // 预约
    if (!StringIsEmpty(signModel.appointmentId)) {
        self.yuImageV.hidden = NO;
    }
    else {
        self.yuImageV.hidden = YES;
    }
    
    // 来自业务端
    if (signModel.fromType == 2) {
        self.yeImageV.hidden = NO;
        // 如果来自预约
        if (!StringIsEmpty(signModel.appointmentId)) {
            self.yeImageVConst.constant = 30;
        }
        else {
            self.yeImageVConst.constant = 10;
        }
    }
    else {
        self.yeImageV.hidden = YES;
    }

    if(signModel.signStatus == 3){
        self.label1.textColor = ColorWithAAAAAA;
        self.label2.textColor = ColorWithAAAAAA;
        self.label3.textColor = ColorWithAAAAAA;
        self.label4.textColor = ColorWithAAAAAA;
        self.label5.textColor = ColorWithAAAAAA;
        self.label6.textColor = ColorWithAAAAAA;
        [self.btn1 setTitleColor:ColorWithAAAAAA forState:UIControlStateNormal];
        self.label7.textColor =  ColorWithAAAAAA;
        self.label7.backgroundColor = [ColorWithAAAAAA colorWithAlphaComponent:0.1];
        self.label8.textColor =  ColorWithAAAAAA;
        self.label8.backgroundColor = [ColorWithAAAAAA colorWithAlphaComponent:0.1];
    }
    
    
}

@end
